package com.shop.cereshop.app.dl.logic.exception;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @description 全局异常拦截器
 * @Author YF
 * @Date 日期:2021/4/13 时间:19:13
 */
@ControllerAdvice  //覆盖SpringMvc自带异常处理
public class DlExceptionController {

    /**
     * 定义处理异常
     */
    @ExceptionHandler(value = DlException.class)
    public ResponseEntity<ExceptionResult> handleException(DlException dlException) {
        return ResponseEntity.status(dlException.getCode()).body(new ExceptionResult(dlException));
    }


}
